Hệ thống hiệu sách thương mại điện tử

1 <?php
2 session_start();

3 if
(!isset($_SESSION['user']))
4        header(
"location: index.php?Message=Login To Continue");
5 ?>
6
7 <!DOCTYPE html>
8 <html lang=
"en">
9 <head>
10
11     <meta charset=
"utf-8">
12     <meta http-equiv=
"X-UA-Compatible" content="IE=edge">
13     <meta name=
"viewport" content="width=device-width, initial-scale=1">
14     <meta name=
"description" content="Books">
15     <meta name=
"author" content="Shivangi Gupta">
16     <title>Online Bookstore</title>
17     <!-- Bootstrap -->
18     <link href=
"css/bootstrap.min.css" rel="stylesheet">
19     <link href=
"css/my.css" rel="stylesheet">
20     <style>
21         #books {margin-bottom: 50px;}
22         @media only screen and (width: 768px) { body{margin-top:150px;}}
23         #books .row{margin-top:30px;margin-bottom:30px;font-weight:
800;}
24         @media only screen and (max-width: 760px) { #books .row{margin-top:10px;}}
25    </style>
26 </head>
27 <body>
28
29     <nav
class="navbar navbar-default navbar-fixed-top navbar-inverse">
30       <div
class="container-fluid">
31         <!-- Brand and toggle
get grouped for better mobile display -->
32         <div
class="navbar-header">
33           <button type=
"button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
34             <span
class="sr-only">Toggle navigation</span>
35             <span
class="icon-bar"></span>
36             <span
class="icon-bar"></span>
37             <span
class="icon-bar"></span>
38           </button>
39           <a
class="navbar-brand" href="index.php"><img alt="Brand" src="img/logo.jpg" style="width: 118px;margin-top: -7px;margin-left: -10px;"></a>
40         </div>
41
42         <!-- Collect the nav links, forms, and other content
for toggling -->
43         <div
class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
44           <ul
class="nav navbar-nav navbar-right">
45               <?php
46                   
if(isset($_SESSION['user']))
47                     {
48                       echo
'
49                     <li><a href=
"cart.php" class="btn btn-md"><span class="glyphicon glyphicon-shopping-cart">Cart</span></a></li>
50                     <li><a href=
"destroy.php" class="btn btn-md"> <span class="glyphicon glyphicon-log-out">LogOut</span></a></li>
51                          
';
52                     }
53                ?>
54           </ul>
55         </div><!-- /.navbar-collapse -->
56       </div><!-- /.container-fluid -->
57     </nav>
58
59
60     <div id=
"top" >
61         <div id=
"searchbox" class="container-fluid" style="width:112%;margin-left:-6%;margin-right:-6%;">
62             <div>
63                 <form role=
"search" action="Result.php" method="post">
64                     <input type=
"text" class="form-control" name="keyword" placeholder="Search for a Book , Author Or Category" style="width:80%;margin:20px 10% 20px 10%;">
65                 </form>
66             </div>
67         </div>
68
69     <?php
70     include
"dbconnect.php";
71         
if(isset($_GET['value']))
72         {
73            $_SESSION[
'author']=$_GET['value'];
74         }
75     $author=$_SESSION[
'author'];
76     
if(isset($_POST['sort']))
77     {
78         
if($_POST['sort']=="price")
79                 { $query =
"SELECT * FROM products WHERE Author='$author' ORDER BY Price";
80                     $result = mysqli_query ($con,$query)or die(mysqli_error($con));
81                 }
82         
else
83         
if($_POST['sort']=="priceh")
84                 { $query =
"SELECT * FROM products WHERE Author='$author' ORDER BY Price DESC";
85                     $result = mysqli_query ($con,$query)or die(mysqli_error($con));
86                 }
87         
else
88         
if($_POST['sort']=="discount")
89                 { $query =
"SELECT * FROM products WHERE Author='$author' ORDER BY Discount DESC";
90                     $result = mysqli_query ($con,$query)or die(mysqli_error($con));
91                 }
92         
else
93         
if($_POST['sort']=="discountl")
94                 { $query =
"SELECT * FROM products WHERE Author='$author' ORDER BY Discount";
95                     $result = mysqli_query ($con,$query)or die(mysqli_error($con));
96                 }
97     }
98     
else
99                   $query =
"SELECT * FROM products WHERE Author='$author'";
100                   $result = mysqli_query ($con,$query)or die(mysql_error());
101     $i=
0;
102     echo
'<div class="container-fluid" id="books">
103         <div
class="row">
104           <div
class="col-xs-12 text-center" id="heading">
105                  <h2 style=
"color:#D67B22;text-transform:uppercase;margin-bottom:0px;"> '. $author .' STORE </h2>
106            </div>
107         </div>
108         <div
class="container fluid">
109              <div
class="row">
110                   <div
class="col-sm-5 col-sm-offset-6 col-md-5 col-md-offset-7 col-lg-4 col-lg-offset-8">
111                        <form action=
"';echo $_SERVER['PHP_SELF'];echo'" method="post" class="pull-right">
112                            <label
for="sort">Sort by &nbsp: &nbsp</label>
113                             <
select name="sort" onchange="form.submit()">
114                                 <option
value="default" name="default" selected="selected">Select</option>
115                                 <option
value="price" name="price">Low To High Price </option>
116                                 <option
value="priceh" name="priceh">Highest To Lowest Price </option>
117                                 <option
value="discountl" name="discountl">Low To High Discount </option>
118                                 <option
value="discount" name="discount">Highest To Lowest Discount</option>
119                             </
select>
120                        </form>
121                   </div>
122               </div>
123         </div>
';
124
125         
if(mysqli_num_rows($result) > 0)
126         {
127             
while($row = mysqli_fetch_assoc($result))
128             {
129             $path=
"img/books/" .$row['PID'].".jpg";
130             $description=
"description.php?ID=".$row["PID"];
131             
if($i%4==0)
132             echo
'<div class="row">';
133             echo
'
134                <a href=
"'.$description.'">
135                 <div
class="col-sm-6 col-md-3 col-lg-3 text-center">
136                     <div
class="book-block" style="border :3px solid #DEEAEE;">
137                         <img
class="book block-center img-responsive" src="'.$path.'">
138                         <hr>
139                          
' . $row["Title"] . '<br>
140                         
' . $row["Price"] .' &nbsp
141                         <span style=
"text-decoration:line-through;color:#828282;"> ' . $row["MRP"] .' </span>
142                         <span
class="label label-warning">'. $row["Discount"] .'%</span>
143                     </div>
144                 </div>
145                 
146                </a>
';
147             $i++;
148             
if($i%4==0)
149             echo
'</div>';
150             }
151         }
152     echo
'</div>';
153     ?>
154
155
156
157     <!-- jQuery (necessary
for Bootstrap's JavaScript plugins) -->
158     <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
159     <!-- Include all compiled plugins (below), or include individual files
as needed -->
160     <script src=
"js/bootstrap.min.js"></script>
161 </body>
162 </html>


Gõ tìm kiếm nhanh...